package com.project.bean;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.time.LocalDate;
import java.util.List;

public class OrderBean {
    /**编号*/
    private int id;
    @NotBlank(message = "收货人必须填写")
    private String name;
    @NotBlank(message = "送货地址必须填写")
    @Pattern(regexp = "[0-9\\u4e00-\\u9fa5]{3,}",message = "送货地址只能包含3位以上的数字和中文")
    private String address;
    @NotBlank(message = "收货人电话必须填写")
    @Pattern(regexp = "1[3578]\\d{9}",message = "电话必须是13、15、17、18开始的11位数")
    private String tel;
    private LocalDate createDate = LocalDate.now();
    /**订单总价*/
    private int price;
    private String state = "未发货";
    /**订单明细集合*/
    private List<OrderInfoBean> infoList;
    /**订单顾客*/
    private UserBean user;

    public OrderBean() {
    }

    public OrderBean(String name, String address, String tel, int price, int userId) {
        this.name = name;
        this.address = address;
        this.tel = tel;
        this.price = price;
        this.user = new UserBean();
        this.user.setId(userId);
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public LocalDate getCreateDate() {
        return createDate;
    }

    public void setCreateDate(LocalDate createDate) {
        this.createDate = createDate;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public List<OrderInfoBean> getInfoList() {
        return infoList;
    }

    public void setInfoList(List<OrderInfoBean> infoList) {
        this.infoList = infoList;
    }

    public UserBean getUser() {
        return user;
    }

    public void setUser(UserBean user) {
        this.user = user;
    }

    @Override
    public String toString() {
        return "OrderBean{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", address='" + address + '\'' +
                ", tel='" + tel + '\'' +
                ", createDate=" + createDate +
                ", price=" + price +
                ", state='" + state + '\'' +
                ", infoList=" + infoList +
                ", user=" + user +
                '}';
    }
}
